{%- macro mmain_menu(data,hierarchy) %}
    {% for key, value in hierarchy %}
        <li{% if data[key]['hr'] is defined %} class="hr"{% endif %}>
            <a href="{{ url(data[key]['href']) }}">
                {% if data[key]['icon'] is defined AND data[key]['icon'] %}<i class="{{ data[key]['icon'] }}"></i>{% endif %}{{ data[key]['name'] }}</a>
            {% if key != value %}
                <ul class="sub-menu">
                    {{ mmain_menu(data,value) }}
                </ul>
            {% endif %}
        </li>
    {% endfor %}
{%- endmacro %}
{{ mmain_menu(data,hierarchy) }}